//
//  LoanDetailsViewController.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/12.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class LoanDetailsViewController: KMViewController {
    
    var model : GenericLoansModel!
    
    init(model:GenericLoansModel) {
        super.init(nibName: nil, bundle: nil)
        
        self.model = model
        
        self.title = model.organization_name! + "-" + model.product_name!
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        addSubView()
    }
    
    //MARK: 添加子视图
    fileprivate func addSubView() {
        
        let loanDetailsVC = LoanDetailsView.init(frame: self.view.bounds, model: self.model)
        loanDetailsVC.delegate = self
        self.view.addSubview(loanDetailsVC)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    

}

extension LoanDetailsViewController : LoanDetailsViewDelegate {
    
    //MARK: 立即申请
    func applyNowAction(model: GenericLoansModel) {
        
        self.navigationController?.pushViewController(WebDetailsViewController.init(urlString: model.link_address), animated: true)
    }
    
    //MARK: 选择贷款类型
    func selectLoanType(model: GenericLoansModel) {
        
        self.title = model.organization_name! + "-" + model.product_name!
    }
}
